package com.yun.util.yun.utils.file;


import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class FileUtils {

    public static byte[] getBytes(String filePath) throws IOException {
        File file = new File(filePath);
        ByteArrayOutputStream out = null;
        FileInputStream in=null;
        try {
            in = new FileInputStream(file);
            out = new ByteArrayOutputStream();
            byte[] b = new byte[1024];
            int i = 0;
            while ((i = in.read(b)) != -1) {
                out.write(b, 0, b.length);
            }
            byte[] s= out.toByteArray();
            return s;
        }finally {
            if(null!=in)
            {
                in.close();
            }
            if(out!=null)
            {
                out.close();
            }
        }
    }
}
